#include "my_header.h"
typedef enum{
    CD = 0,
    LS,
    LL,
    PWD,
    PUTS,
    GETS,
    REMOVE,
    MKDIR,
    RMDIR,
    QUIT
}commandType;

typedef struct TLVtrain_s{
    commandType type;
    int length;
    char data[4096];
}TLVtrain_t;

typedef struct train_s{
    int length;
    char data[4096];
}train_t;

typedef struct client_s{
    int fd;
    char userName[1024];
    char pwd[1024];
    char baseDir[1024];
}client_t;

typedef struct pathnode_t{
    char filePath[1024];
    struct pathnode_t *prev;
    struct pathnode_t *next;
} PathNode;

typedef struct pathStack_t{
    PathNode *top;
    PathNode *bottom;
    int size;
} PathStack;

//创建节点
PathNode *pathnode_create(char *realpath);
//初始化栈
PathStack *pathstack_init();
//入栈
void pathstack_push(char *realpath,PathStack *stack);
//弹栈
void pathstack_pop(PathStack *stack);
//销毁栈
void pathstack_free(PathStack *stack);
//打印栈
void print_stack(PathStack *stack);

int workCmd(int netFd);

int sendFile(int netFd,char *file);
int recvFile(int netFd);
int recvn(int sockfd, void *buf, int length);

int doCd(client_t *pclient,char *path);
int doLs(client_t *pclient);
int doLl(client_t *pclient);
/* int doPwd(client_t *pclient); */
int doPuts(client_t *pclient);
int doGets(client_t *pclient,char *file);
int doRemove(client_t *pclient,char *file);
int doMkdir(client_t *pclient,char *dir);
int doRmdir(client_t *pclient,char *dir);

int sysadd(client_t *pclient,char *cmd);
